//
//  MJRefreshComponent+RefreshStyle.m
//  ArtDog
//
//  Created by dllo on 16/9/2.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "MJRefreshComponent+RefreshStyle.h"
#import "MJRefreshNormalHeader.h"
#import "MJRefreshAutoNormalFooter.h"

@implementation MJRefreshComponent (RefreshStyle)

- (void)mjRefreshStateHeaderStyle
{
    if (![self isKindOfClass:[MJRefreshStateHeader class]]) {
        return;
    }
    MJRefreshStateHeader *header = (MJRefreshStateHeader *)self;
    [header setTitle:@"松开立即刷新" forState:MJRefreshStatePulling];
    [header setTitle:@"正在刷新数据中" forState:MJRefreshStateRefreshing];
    [header setTitle:@"下拉可以刷新" forState:MJRefreshStateIdle];
    header.lastUpdatedTimeText = ^(NSDate *lastUpdatedTime) {
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
        NSDate *currentDate = [NSDate date];
        [dateFormatter setDateFormat:@"yyyy年MM月dd日"];
        if ([[dateFormatter stringFromDate:lastUpdatedTime] isEqualToString:[dateFormatter stringFromDate:currentDate]]) {
            [dateFormatter setDateFormat:@"hh:mm"];
            NSString *dateString = [NSString stringWithFormat:@"更新时间：今天%@", [dateFormatter stringFromDate:lastUpdatedTime]];
            return dateString;
        } else {
            NSString *dateString = [NSString stringWithFormat:@"更新时间：%@", [dateFormatter stringFromDate:lastUpdatedTime]];
            return dateString;
        }
    };
    
}

- (void)mjRefreshAutoStateFooterStyle
{
    if (![self isKindOfClass:[MJRefreshAutoNormalFooter class]]) {
        return;
    }
    MJRefreshAutoNormalFooter *footer = (MJRefreshAutoNormalFooter *)self;
    [footer setTitle:@"松开立即刷新" forState:MJRefreshStatePulling];
    [footer setTitle:@"正在加载更多数据" forState:MJRefreshStateRefreshing];
    [footer setTitle:@"已经全部加载完毕" forState:MJRefreshStateNoMoreData];
    [footer setTitle:@"数据正在加载中，请稍等" forState:MJRefreshStateIdle];
}


@end
